<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <h1 id="txt">开始抽奖</h1>
        <button id="start">开始</button>
        <button id="end">结束</button>
        <p>一等奖为在线退学</p>
        <p>二等奖为上完课</p>
        <script>
            var txt=document.getElementById('txt')
            var start=document.getElementById('start')
            var end=document.getElementById('end')
            var user=['二号','以号','三号','四号','恭喜你','再接再厉'];
            var timer;
           
            start.onclick=function(){
                
                clearInterval(timer)
               timer=setInterval(function(){
                    var n=parseInt(Math.random()*user.length);
                    txt.innerHTML=user[n];
                },100)
            }
            end.onclick=function(){
                
                clearInterval(timer)
            }
        </script>
    </body>
</html>
